//
//  QYOrderListCell.m
//  QingYue
//
//  Created by Zheng on 2019/3/26.
//  Copyright © 2019 com.lanou.product_A. All rights reserved.
//

#import "QYOrderListCell.h"


@implementation QYOrderListCell

- (void)setModel:(QYOrderListModel *)model {
    _model = model;
    
    [_bookImgv sd_setImageWithURL:[NSURL URLWithString:_model.BookPic] placeholderImage:[UIImage imageNamed:@"图书占位.jpg"]];
    _bookNameLbl.text = _model.BookName;
    _addDateLbl.text = [NSString stringWithFormat:@"申请日期：%@",_model.CreateTime];
    _orderNumLbl.text = [NSString stringWithFormat:@"订单号：%@",_model.RecordNumber];
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setSelectionStyle:UITableViewCellSelectionStyleNone];
        
        UIView *bgView = [[UIView alloc] init];
        bgView.layer.masksToBounds = YES;
        bgView.layer.cornerRadius = 5;
        bgView.layer.borderColor = [UIColor lightGrayColor].CGColor;
        bgView.layer.borderWidth = 0.5;
        [self.contentView addSubview:bgView];
        [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(15);
            make.width.height.mas_equalTo(110);
            make.centerY.equalTo(self);
        }];
        
        _bookImgv = [[UIImageView alloc] init];
        _bookImgv.image = [UIImage imageNamed:@"图书占位.jpg"];
        [bgView addSubview:_bookImgv];
        [_bookImgv mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(115*0.6);
            make.height.mas_equalTo(150*0.6);
            make.centerX.centerY.equalTo(bgView);
        }];
        
        _bookNameLbl = [[UILabel alloc] init];
        _bookNameLbl.font = [UIFont boldSystemFontOfSize:19];
        [self.contentView addSubview:_bookNameLbl];
        [_bookNameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(bgView.mas_right).offset(20);
            make.top.equalTo(bgView).offset(5);;
            make.right.mas_equalTo(-15);
        }];
        
        _orderNumLbl = [[UILabel alloc] init];
        _orderNumLbl.font = [UIFont systemFontOfSize:12];
        _orderNumLbl.textColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_orderNumLbl];
        [_orderNumLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bookNameLbl);
            make.top.equalTo(self.bookNameLbl.mas_bottom).offset(10);
        }];
        
        _addDateLbl = [[UILabel alloc] init];
        _addDateLbl.font = [UIFont systemFontOfSize:12];
        _addDateLbl.textColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_addDateLbl];
        [_addDateLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.orderNumLbl);
            make.top.equalTo(self.orderNumLbl.mas_bottom).offset(3);
        }];
        
        _markLbl = [[UILabel alloc] init];
        _markLbl.font = [UIFont systemFontOfSize:11];
        _markLbl.textColor = [UIColor whiteColor];
        _markLbl.textAlignment = NSTextAlignmentCenter;
        _markLbl.backgroundColor = MyGreenColor;
        _markLbl.layer.masksToBounds = YES;
        _markLbl.text = @"查看详情";
        
        _markLbl.layer.cornerRadius = 3;
        [self.contentView addSubview:_markLbl];
        [_markLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(65);
            make.height.mas_equalTo(20);
            make.left.equalTo(self.orderNumLbl);
            make.bottom.equalTo(bgView).offset(-5);
        }];
        
        
    }
    return self;
}


@end
